﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BookMarkManagement.aspx.cs" Inherits="SkWeb.FASJ.BookMarkManagement" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
       <link  id="MyCss" href="../COMMON/CSS/Default.css" rel="stylesheet" type="text/css" />
     <script type="text/javascript" language="javascript" src="../COMMON/JS/changerows.js" ></script>

    <script src="../js/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script src="../js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>

    <link href="../js/wijmo-dialog/ui-themes/aristo/jquery-wijmo.css" rel="stylesheet" type="text/css" />
    <link href="../js/wijmo-dialog/ui-themes/wijmo/jquery.wijmo.wijdialog.css" rel="stylesheet" type="text/css" />
    <script src="../js/wijmo-dialog/jquery.wijmo-open.1.4.1.min.js" type="text/javascript"></script>

    <script src="../js/hu8-box/languages/zh.js" type="text/javascript"></script>
    <script src="../js/hu8-box/hu8.box.js" type="text/javascript"></script>
    <link href="../easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../easyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../easyui/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../easyui/jquery.easyui.min.js" type="text/javascript"></script>
        <!-- Wijmo dialog -->
  
  
    <style type="text/css">
        #fm{
            margin:0;
            padding:10px 30px;
        }
        .ftitle{
            font-size:14px;
            font-weight:bold;
            padding:5px 0;
            margin-bottom:10px;
            border-bottom:1px solid #ccc;
        }
        .fitem{
            margin-bottom:5px;
        }
        .fitem label{
            display:inline-block;
            width:80px;
        }
        
       .file-box{ position:relative;width:340px} 
       .txt{ height:22px; border:1px solid #cdcdcd; width:180px;} 
       .btn{ background-color:#FFF; border:1px solid #CDCDCD;height:24px; width:70px;} 
       .file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px } 
       
    </style>

     <script type="text/javascript">
         var row_id;
         function addBK(obj) {
           // box.open_window('上传模板文档', "../Handlers/FileUploader.aspx?TmpUrl=100" , 500, 400, true);
            $('#dlg').dialog('open').dialog('setTitle', '添加书签');
         }
         function saveInfo() {
             var url_tmp = "bookMarkHander.aspx?action=add";

             if ($('#dlg').panel('options').title == "修改书签") {
                // var row = $('#tt').datagrid('getSelected');
                 url_tmp = "bookMarkHander.aspx?action=update&id=" + row_id;
             }
	
           
             $('#fm').form('submit', {
                 url: url_tmp,
                 onSubmit: function () {
                     return $(this).form('validate');
                 },
                 success: function (result) {
                     result = eval('(' + result + ')');
                     if (!result.success) {
                         $.messager.show({
                             title: 'Error',
                             msg: result.msg
                         });
                     } else {
                         $('#dlg').dialog('close');        // close the dialog
                         location.reload();
                     }
                 }
             });
         }

         function editInfo(obj) {
            
             var tmp = $(obj).parent().parent()[0].children[0]
             var o = {};
             o.name=$(tmp).text();
             tmp = $(obj).parent().parent()[0].children[1];
             o.text=$(tmp).text();
             tmp = $(obj).parent().parent()[0].children[2];
             o.field_name = $(tmp).text().toUpperCase();
             tmp = $(obj).parent().parent()[0].children[3];
             o.default_varl=$.trim($(tmp).text());
             tmp = $(obj).parent().parent()[0].children[4];
             o.multi_val = $.trim($(tmp).text()); //$(tmp).text();
             tmp = $(obj).parent().parent()[0].children[5];
             o.formula = $.trim($(tmp).text());

             tmp = $(obj).parent().parent()[0].children[6];
             o.xh = $.trim($(tmp).text());
             tmp = $(obj).parent().parent()[0].children[7];
             if ($(tmp).find('input').is(':checked'))
                 o.xs = "on";
             else {
                 o.xs = "off";
             }

             tmp = $(obj).parent().parent()[0].children[8];
             row_id = $(tmp).find('input').val();
             
             if (o) {
                 $('#dlg').dialog('open').dialog('setTitle', '修改书签');
                  $('#fm').form('load', o);
                 // url = 'FormAction.aspx?action=update&id=' + row.id;
             }
          }

          function addTp() {
        
              $("#dialogSchemeType").dialog("open");

            }


            $(function () {

                //上传文档
                $("#btnzdsc").click(function () {
                    //$("#dialogSchemeType").dialog("close");
                    //$("#dialogColumnParams").dialog("open");
                    var node = $("#divtemplate").treegrid("getSelected");

                    if (node && node.children[0]) {
                        //$("#hiddenTempalteID").val(node.TMP_ID);
                        //var path = encodeURI(filemanager.get_path());
                       // box.open_window('上传模板文档', "../Handlers/FileUploader.aspx?TmpUrl=" + node.children[0].TmpUrl, 500, 400, true);
                        var url = "../Handlers/FileUploader.aspx?TmpID=" + node.TMP_ID;
                        $("#uploadFrame").attr('src', url);
                        $("#divTmp").dialog("open");
                    }
                    else {
                        alert("请选择存放路径");
                    }
                    //                    var data = "";

                    //                    table_ = document.getElementById("tab_data");
                    //                    for (var i = 1; i < table_.rows.length - 1; i++) {
                    //                        var obj = table_.rows[i].getElementsByTagName("input");
                    //                        if (obj.length == 0)
                    //                            obj = table_.rows[i].getElementsByTagName("select");
                    //                        bookmarkName = obj[0].name;
                    //                        inputValue = obj[0].value;
                    //                        data += inputValue + ',' + bookmarkName + ';';
                    //                    }
                    //TODO: 添加弹出 window 方法
                    // var opt = 'top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no';
                    // window.open("../FAXZ/WordBrowse.aspx?op=browseFromLFS&id=" + $("#txtHiddenId").val() + "&tempalteid=" + $("#hiddenTempalteID").val() + "&message=" + message + "&data=" + data, "", opt);


                    //     document.getElementById("frame").src = "../FAXZ/WordBrowse.aspx?op=browseFromLFS&id=" + $("#txtHiddenId").val() + "&tempalteid=" + $("#hiddenTempalteID").val() + "&message=" + message;
                    //      $('#w').window('open');
                    //                var win = window.open("../FAXZ/WordBrowse.aspx?id=" + $("#txtHiddenId").val() + "&tempalteid=" + $("#hiddenTempalteID").val(), "",
                    //                 "top=0,left=0,scrollbars=no,status=0,directory=0,location=0");
                    //                var h = screen.availHeight;
                    //                var w = screen.availWidth; 
                    //                win.resizeTo(w, h);

                });

                //人工干预
                $("#btnrggy").click(function () {
                    //$("#dialogSchemeType").dialog("close");
                    //                    var node = $("#divtemplate").treegrid("getSelected");
                    //                    if (node&& node.children[0]) {
                    //                        //$("#hiddenTempalteID").val(node.TMP_ID);
                    //                        //var path = encodeURI(filemanager.get_path());
                    //                        box.open_window('上传模板文档', "../Handlers/FileUploader.aspx?TmpUrl=" + node.children[0].TmpUrl, 500, 400, true);
                    //                    }
                    //                    else {
                    //                        alert("请选择存放路径");
                    //                    }

                    //                    document.getElementById("frame").src = "../FAXZ/ExcelBrowse.aspx?id=" + $("#txtHiddenId").val() + "&tempalteid=" + $("#hiddenTempalteID").val();
                    //                    $('#w').window('open');
                    //TODO: 添加弹出 window 方法
                });

                $("#divtemplate").treegrid({
                    url: '../Handlers/SchemeDesignHandler.aspx?op=gettemplatetree&pid=11001',
                    idField: 'TMP_ID',
                    treeField: 'TMP_MC',
                    columns: [[
                    { title: '模版分类', field: 'TMP_MC', width: 480 }
                ]],
                    onClickRow: function (row) {
                        // if (row.getChildren(row.id).length > 0) {
                        $('#divtemplate').treegrid('toggle', row.TMP_ID);
                        // }
                    }
                });

                //点击灌输射孔
                $("#btngssk").click(function () {
                    $("#divtemplate").treegrid({
                        url: '../Handlers/SchemeDesignHandler.aspx?op=gettemplatetree&pid=1001',
                        idField: 'TMP_ID',
                        treeField: 'TMP_MC',
                        columns: [[
                    { title: '模版分类', field: 'TMP_MC', width: 480 }
                ]]
                    });
                });

                //点击电缆射孔
                $("#btndlsk").click(function () {
                    $("#divtemplate").treegrid({
                        url: '../Handlers/SchemeDesignHandler.aspx?op=gettemplatetree&pid=1053',
                        idField: 'TMP_ID',
                        treeField: 'TMP_MC',
                        columns: [[
                    { title: '模版分类', field: 'TMP_MC', width: 480 }
                ]]
                    });
                });

                //点击作业施工
                $("#btnzysg").click(function () {
                    $("#divtemplate").treegrid({
                        url: '../Handlers/SchemeDesignHandler.aspx?op=gettemplatetree&pid=1054',
                        idField: 'TMP_ID',
                        treeField: 'TMP_MC',
                        columns: [[
                    { title: '模版分类', field: 'TMP_MC', width: 480 }
                ]]
                    });
                });



            });


 

     </script>
</head>
<body>
    <form id="form1" runat="server">
     <div >
     <table   border="1" cellpadding="5" cellspacing="0" class="table_bordercolor" height="600px" width="100%" id="TABLE1" runat="server">
          <tr>
                            <td  colspan="6" style="height: 16px; text-align: center; width:100%" valign="top" bgcolor="#3cb6e5">
                                【 <strong>书签管理</strong>】
                                </td>
                        </tr>
                       <%-- <tr style="width: 210px; height: 22px;" class="r_bg" >
                        <td colspan="2" width="200px">选择表：&nbsp;
                   
                        </td>
                        <td colspan="2" width="200px">备注：
                       <asp:TextBox ID="txtComment" runat="server">
                            </asp:TextBox>
                            
                       
                        </td>
                        <td colspan="1" width="100px">
                       
                            <asp:Button ID="btnMdyCom" runat="server" Text="修改备注" OnClientClick="return fun()" >
                            </asp:Button>
                       
                        </td><td colspan="1" width="200px" style=" text-align:left">
                       
                            <asp:Label ID="labMessage" runat="server" Text="提示信息"></asp:Label>
                        </td>
                         
                         </tr>--%>
                        <tr valign="top"  style ="height:40%; width:900px; " id="GridUser2">
                        <td  colspan="6" style="height: 16px; text-align: center; width:100%" valign="top" align="center">
        <table style=" width:100%;margin:auto" >
   
            
            <tr style=" vertical-align:top;">
                <td >
                 <div  style="overflow:auto; height:550px">
                    <asp:GridView ID="GridView1" CssClass="gridview"   runat="server" OnRowCommand="gv_RowCommand"
                        AutoGenerateColumns="False" CellPadding="4"
                        ForeColor="#333333" GridLines="None"
                       Width="100%" AllowPaging="False" Font-Size="Medium" >
                        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White"/>
                        <RowStyle Wrap="true" Height="15px" />
                        <Columns>
                          
                             <asp:BoundField DataField="name"  HeaderText="名称" HeaderStyle-Width="10%" ReadOnly="True" />
                             <asp:BoundField DataField="text"  HeaderText="书签名" HeaderStyle-Width="10%" ReadOnly="True" />
                             <asp:BoundField DataField="field_name"  HeaderText="字段名" HeaderStyle-Width="8%" ReadOnly="True" />
                             <asp:BoundField DataField="default_varl"  HeaderText="默认值" HeaderStyle-Width="5%" ReadOnly="True" />
                           <%--  <asp:BoundField DataField="multi_val"  HeaderText="多选列表" HeaderStyle-Width="37%" ReadOnly="True" >
                            <ItemStyle Width="100px" /> 
                             </asp:BoundField>--%>
                             <asp:TemplateField HeaderText="多选列表" Visible="true" >
                                <HeaderStyle Width="300px" />
                                <ItemTemplate>
                                 <asp:TextBox   TextMode="MultiLine" runat="server" ID="txtComment" Text='<%#Eval("multi_val")%>' Width="98%" Height="40px"/>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <%-- <asp:TemplateField ItemStyle-HorizontalAlign="center" HeaderStyle-Width="30%">
                              <HeaderStyle Width="150px" />
                                <ItemTemplate>
                                    <asp:TextBox Width="100%" ID="multi_lab" runat="server" Text='' />
                                </ItemTemplate>
                             </asp:TemplateField>--%>

                             <asp:BoundField DataField="formula"  HeaderText="公式" HeaderStyle-Width="20%" ReadOnly="True" />
                             <asp:BoundField DataField="xh"  HeaderText="顺序" HeaderStyle-Width="40px" ReadOnly="True" />
   
                              <asp:TemplateField HeaderText="显示" Visible="true" >
                              <HeaderStyle Width="40px"  />
                             <ItemTemplate>
                              <asp:CheckBox  runat="server"  onclick="return false"   ID="ck_show"  Checked='<%# Eval("xs").ToString().Trim()=="1"%>'  />
                             </ItemTemplate>
                             </asp:TemplateField>
                            <%-- <asp:TemplateField ItemStyle-HorizontalAlign="center">
                <ItemTemplate>
                    <asp:LinkButton ID="lbtnDeleteTicket" runat="server" CommandName="link" CommandArgument='<%# ("FINANCE_TICKET_ID") %>'>删除</asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>--%>
                             <asp:TemplateField HeaderText="管理" Visible="true" >
                                <HeaderStyle Width="10%" />
                                <ItemTemplate>
                               
                                 <a id="lbtEdit"  onclick="editInfo(this)" > 修改</a>
                                 <asp:LinkButton ID="lbtnDelete" runat="server" CommandName="delete_" CommandArgument='<%#Eval("id")%>' >删除</asp:LinkButton>
                                 <asp:HiddenField ID="id_val" runat="server" Value='<%#Eval("id")%>'  />
                                </ItemTemplate>
                            </asp:TemplateField>
                             
                     
                        </Columns>
                        <RowStyle ForeColor="#000066" />
                        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                      <PagerSettings Visible="False" />
                    </asp:GridView>
                     </div>
                </td>
            </tr>
        </table>
        </td>
        </tr>
            <tr >
                          <td  colspan="6"  align="center" bgcolor="#3cb6e5">
                        <%-- <asp:Button ID="btnAdd" Text="添加" runat="server"    CssClass="submit"/>--%>
                          <input id="btnAdd" type="button" value="添加书签"  class="submit" onclick="addBK()" />     
                          <input id="Button1" type="button" value="添加新模板"  class="submit" onclick="addTp()" />      
                        </td>
                        </tr>
            
        </table>
  
                
    </div>
  
    </form>

      <div  id="dlg" class="easyui-dialog" style="width:400px;height:480px;padding:10px 20px; font-size:16px"
            closed="true" buttons="#dlg-buttons">
        <div class="ftitle">井信息</div>
        <form id="fm" method="post"   novalidate>
            
            <div class="fitem">
                <label>名称:</label>
                <input name="name" class="easyui-validatebox" required="true"/>
            </div>

            <div class="fitem">
                <label>书签名:</label>
                <input name="text" class="easyui-validatebox" required="true"/>
            </div>
        <div class="fitem">
            <label>
                字段名:</label>
            <select name="field_name">
                <option value=""></option>
                <option value="_TIME_NOW_">当前时间</option>
                <option value="LRRQ">LRRQ () </option>
                <option value="JH">JH (井号) </option>
                <option value="JB">JB (井别) </option>
                <option value="CB">CB (厂别) </option>
                <option value="WJFS">WJFS () </option>
                <option value="SGLX">SGLX (施工类型) </option>
                <option value="SKQX">SKQX () </option>
                <option value="SKDX">SKDX () </option>
                <option value="CSFS">CSFS (传输方式) </option>
                <option value="CYSXH">CYSXH () </option>
                <option value="YGLX">YGLX () </option>
                <option value="YGGG">YGGG (油管规格) </option>
                <option value="SJYGWGSD">SJYGWGSD () </option>
                <option value="TSSGLX">TSSGLX () </option>
                <option value="SYYL">SYYL () </option>
                <option value="TGDJG">TGDJG () </option>
                <option value="ZLHSD">ZLHSD () </option>
                <option value="SKMD">SKMD () </option>
                <option value="XW">XW () </option>
                <option value="FY">FY () </option>
                <option value="WJYMC">WJYMC () </option>
                <option value="WJYMD">WJYMD () </option>
                <option value="WJYYL">WJYYL () </option>
                <option value="SKJD1">SKJD1 () </option>
                <option value="SKJD2">SKJD2 () </option>
                <option value="SKHD">SKHD () </option>
                <option value="YSK">YSK () </option>
                <option value="JSDW">JSDW () </option>
                <option value="LRR">LRR () </option>
                <option value="SHR">SHR (审核人) </option>
                <option value="BKCS">BKCS () </option>
                <option value="YL">YL () </option>
                <option value="BZ1">BZ1 () </option>
                <option value="OK">OK () </option>
                <option value="TRANS">TRANS () </option>
                <option value="CSRQ">CSRQ () </option>
                <option value="XH">XH () </option>
                <option value="SKDX1">SKDX1 () </option>
                <option value="YSK1">YSK1 () </option>
                <option value="SKMD1">SKMD1 () </option>
                <option value="YGLX1">YGLX1 () </option>
                <option value="SJYGWGSD1">SJYGWGSD1 () </option>
                <option value="YGGG1">YGGG1 (油管规格) </option>
                <option value="BKGS">BKGS () </option>
                <option value="ZJYLX">ZJYLX () </option>
                <option value="SKQX2">SKQX2 () </option>
                <option value="SKHD2">SKHD2 () </option>
                <option value="QK">QK () </option>
                <option value="KB">KB () </option>
                <option value="DATAMIGRATION_ID">DATAMIGRATION_ID () </option>
                <option value="DCYL">DCYL () </option>
                <option value="TSJ">TSJ () </option>
                <option value="YCZBSD">YCZBSD () </option>
                <option value="XCS">XCS () </option>
                <option value="TGTZBXG">TGTZBXG () </option>
                <option value="SKBJ">SKBJ () </option>
                <option value="SGDW">SGDW () </option>
                <option value="BZ">BZ () </option>
                <option value="SHRQ">SHRQ () </option>
                <option value="SHWTGYY">SHWTGYY () </option>
                <option value="SHZT">SHZT () </option>
                <option value="CJ">CJ () </option>
            </select>
            <%--<input name="field_name" class="easyui-validatebox" required="true"/>--%>
        </div>

            <div class="fitem">
                <label>默认值:</label>
                <input name="default_varl" class="easyui-validatebox" />
            </div>

            <div class="fitem">
                <label>多选值:</label>
                <textarea name="multi_val" style=" height:80px; width:200px"></textarea> 
            </div>

            <div class="fitem">
                <label>公式:</label>
                <textarea name="formula" style=" height:80px; width:200px"></textarea> 
            </div>
             <div >
                <label>顺序:</label>
                <input name="xh" style=" height:20px; width:100px"/>&nbsp&nbsp
                <input name="xs"  type="checkbox"   /> 显示
            </div>
 
        </form>
    </div>
   <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()">Save</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
    </div>




     <!-- 选择方案类型 -->
    <div id="dialogSchemeType" class="easyui-dialog" title="选择方案类型"  style="width:600px;height:450px"
    data-options="closed:true, collapsible:false, maximizable:false, minimizable:false, buttons:'#dlg-buttons1'">
        <div style=" margin-left:1px; margin-top:1px;">
            
            <div style=" margin:2px;">
                <a class="easyui-linkbutton" href="javascript:void(0)" id="btngssk">管输射孔</a>
                <a class="easyui-linkbutton" href="javascript:void(0)" id="btndlsk">电缆射孔</a>
                <a class="easyui-linkbutton" href="javascript:void(0)" id="btnzysg">作业施工</a>
            </div>

            <table id="divtemplate" style="width:500px; height:320px; margin:2px;">
            	
            </table>
            
            <!-- 保存选择的模版ID -->
            <input type="hidden" id="hiddenTempalteID" />
        </div>
        
    </div>

    <div id="dlg-buttons1">
    
  
        <a href="javascript:void(0)" class="easyui-linkbutton" id="btnzdsc" >上传模板</a>
       <%-- <a href="javascript:void(0)" class="easyui-linkbutton" id="btnrggy" ></a>--%>
        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#dialogSchemeType').dialog('close')">关闭</a>

    </div>



    <div id="divTmp" class="easyui-dialog" title="选择方案模板"  style="width:450px;height:360px"
    data-options="closed:true, collapsible:false, maximizable:false, minimizable:false">
        <div style=" margin-left:1px; margin-top:1px;">
            
         <iframe id="uploadFrame" src="" width='97%', height="375px"/>
            
            <!-- 保存选择的模版ID -->
            <input type="hidden" id="hidden1" />
        </div>
        
    </div>


</body>
</html>